package net.oschina.app.adapter.explore;

import android.databinding.DataBindingUtil;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;

import net.oschina.app.R;
import net.oschina.app.adapter.BaseRecyclerViewAdapter;
import net.oschina.app.bean.Event;
import net.oschina.app.databinding.ViewEventRvItemBinding;

import java.util.List;

/**
 * Created by wuer on 2017/4/8/008.
 * 近期活动界面的数据获取以及跳转到活动详情界面
 */

public class RecentlyAdapter extends BaseRecyclerViewAdapter {
    private List<Event> mEvent;
    public RecentlyAdapter(List<Event> events){
        super();
        this.mEvent=events;
    }

    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View itemView=mInflater.inflate(R.layout.view_event_rv_item,parent,false);
        RecentlyAdapter.EventsHolder holder=new RecentlyAdapter.EventsHolder(itemView);
        return holder;
    }
    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        super.onBindViewHolder(holder, position);
        EventsHolder newsHolder= (EventsHolder) holder;
        Event events=mEvent.get(position);
        //活动页面数据绑定
        ViewEventRvItemBinding binding = DataBindingUtil.bind(newsHolder.itemView);
        binding.setImageUrl(events.getCover());
        binding.setEvent(events);
    }
    @Override
    public int getItemCount() {
        return mEvent.size();
    }
    public class EventsHolder extends RecyclerView.ViewHolder{
        public EventsHolder(View itemView) {
            super(itemView);
        }
    }
}
